﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 委托04_Action
{
    class Program
    {
        static void Main(string[] args)
        {
            // Action是系统提供的没有返回值的委托
            Action a = PrintHelloWorld;
            a();

            Action<string> b = PrintString;
            b("asdfg");

            Action<int, double, string, bool> c = PrintString;
            c(1, 1.2, "str", true);

            // Action<Tn>可以通过泛型去指定方法的多个参数类型
            // 被委托方法的参数类型必须要与Action声明时后面泛型的参数类型一致
        }

        public static void PrintHelloWorld()
        {
            Console.WriteLine("Hello World.");
        }
        public static void PrintString(string str)
        {
            Console.WriteLine(str);
        }
        public static void PrintString(int a, double b, string c, bool d)
        {
            Console.WriteLine("{0} {1} {2} {3}", a, b, c, d);
        }
    }
}
